package com.jyw.business.obstacles.wechat.controller;

import com.jyw.business.obstacles.domain.dto.wechat.WechatOrderAddDto;
import com.jyw.business.obstacles.service.IObsOrderFaultService;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.utils.DateUtils;
import com.jyw.system.domain.vo.SysOrderExpectedTimeConfigVo;
import com.jyw.system.service.ISysOrderExpectedTimeConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 沈峻
 * @ClassName ObsServerController
 * @Description 报障
 * @Date 2023/8/10 15:30
 **/
@RestController
@RequestMapping("/wechat/obstacles/report")
@Api(tags = "报障")
public class ObsWeChatReportController extends BaseController {

    @Resource
    private IObsOrderFaultService orderFaultService;

    @Resource
    private ISysOrderExpectedTimeConfigService sysOrderExpectedTimeConfigService;

    @PostMapping("addOrder")
    @PreAuthorize("@ss.hasPermi('obstacles:server:add')")
    @ApiOperation("创建工单")
    public CommonResult add(@RequestBody WechatOrderAddDto addDto){
        //匹配期望完成时间
        addDto.setCompleteType(sysOrderExpectedTimeConfigService.getExpectedTimeType(DateUtils.castDateToLocalDateTime(addDto.getCreateTime())));
        orderFaultService.add(addDto);
        return CommonResult.success();
    }

}
